package com.siblings.loan.ui.loan.adapter

import android.graphics.Color
import androidx.recyclerview.widget.RecyclerView
import com.siblings.lib_baseadapter.SIBRecyclerViewAdapter
import com.siblings.lib_baseadapter.SIBViewHolderHelper
import com.siblings.loan.R
import org.json.JSONObject

/**
 * Siblings
 * @Author wwdeng
 * @CreateTime: 2024/7/15 14:42
 * @Annotation：贷款申请 选择时间 适配器
 */
class SibLoanApplyDaysAdapter(recyclerView: RecyclerView?) : SIBRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.item_loan_apply_days) {
    override fun setItemChildListener(helper: SIBViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.textDays) //点击Item
    }

    override fun fillData(helper: SIBViewHolderHelper, position: Int, model: JSONObject) {
        val textDays = helper.getTextView(R.id.textDays)
        textDays.text = model.optString("day")

        if (model.optBoolean("isSelect",false)){
            textDays.setBackgroundResource(R.drawable.sib_loan_apply_days)
            textDays.setTextColor(Color.parseColor("#FF4DB673"))
        } else {
            textDays.setBackgroundResource(R.drawable.sib_radius_fill_fff9f9f9_12)
            textDays.setTextColor(Color.parseColor("#FF999999"))
        }
    }
}